home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / graphics / tiff / tools / tiffcp.c < prev    next >
C/C++ Source or Header  |  1992-03-26  |  15KB  |  551 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Header: /usr/people/sam/tiff/tools/RCS/tiffcp.c,v 1.19 92/03/27 12:11:24 sam Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Copyright (c) 1988, 1989, 1990, 1991, 1992 Sam Leffler
  7.  * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
  8.  *
  9.  * Permission to use, copy, modify, distribute, and sell this software and 
  10.  * its documentation for any purpose is hereby granted without fee, provided
  11.  * that (i) the above copyright notices and this permission notice appear in
  12.  * all copies of the software and related documentation, and (ii) the names of
  13.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  14.  * publicity relating to the software without the specific, prior written
  15.  * permission of Sam Leffler and Silicon Graphics.
  16.  * 
  17.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  18.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  19.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  20.  * 
  21.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  22.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  23.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  24.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  25.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  26.  * OF THIS SOFTWARE.
  27.  */
  28.  
  29. #include <stdio.h>
  30. #include "tiffio.h"
  31.  
  32. typedef    unsigned char u_char;
  33. typedef    unsigned short u_short;
  34. typedef    unsigned int u_int;
  35. typedef    unsigned long u_long;
  36.  
  37. #if defined(VMS)
  38. #define unlink delete
  39. #endif
  40.  
  41. #define    streq(a,b)    (strcmp(a,b) == 0)
  42. #define    CopyField(tag, v) \
  43.     if (TIFFGetField(in, tag, &v)) TIFFSetField(out, tag, v)
  44. #define    CopyField2(tag, v1, v2) \
  45.     if (TIFFGetField(in, tag, &v1, &v2)) TIFFSetField(out, tag, v1, v2)
  46. #define    CopyField3(tag, v1, v2, v3) \
  47.     if (TIFFGetField(in, tag, &v1, &v2, &v3)) TIFFSetField(out, tag, v1, v2, v3)
  48. #define    CopyField4(tag, v1, v2, v3, v4) \
  49.     if (TIFFGetField(in, tag, &v1, &v2, &v3, &v4)) TIFFSetField(out, tag, v1, v2, v3, v4)
  50.  
  51. static    short config;
  52. static    u_short compression;
  53. static    u_short predictor;
  54. static    u_short fillorder;
  55. static    long rowsperstrip;
  56. static    long g3opts;
  57. static    int ignore = 0;            /* if true, ignore read errors */
  58. static    char *filename;
  59.  
  60. static    int tiffcp();
  61. static    int cpContig2ContigByRow();
  62. static    int cpContig2SeparateByRow();
  63. static    int cpSeparate2ContigByRow();
  64. static    int cpSeparate2SeparateByRow();
  65. static    int cpDecodedStrips();
  66. static    void usage();
  67.  
  68. main(argc, argv)
  69.     char *argv[];
  70. {
  71.     short defconfig = -1;
  72.     u_short defcompression = -1;
  73.     u_short defpredictor = 0;
  74.     u_short deffillorder = 0;
  75.     long defrowsperstrip = -1;
  76.     long defg3opts = 0;
  77.     TIFF *in, *out;
  78.  
  79.     argc--, argv++;
  80.     if (argc < 2)
  81.         usage();
  82.     for (; argc > 2 && argv[0][0] == '-'; argc--, argv++) {
  83.         if (streq(argv[0], "-none")) {
  84.             defcompression = COMPRESSION_NONE;
  85.             continue;
  86.         }
  87.         if (streq(argv[0], "-packbits")) {
  88.             defcompression = COMPRESSION_PACKBITS;
  89.             continue;
  90.         }
  91.         if (streq(argv[0], "-lzw")) {
  92.             defcompression = COMPRESSION_LZW;
  93.             continue;
  94.         }
  95.         if (streq(argv[0], "-g3")) {
  96.             defcompression = COMPRESSION_CCITTFAX3;
  97.             continue;
  98.         }
  99.         if (streq(argv[0], "-g4")) {
  100.             defcompression = COMPRESSION_CCITTFAX4;
  101.             continue;
  102.         }
  103.         if (streq(argv[0], "-contig")) {
  104.             defconfig = PLANARCONFIG_CONTIG;
  105.             continue;
  106.         }
  107.         if (streq(argv[0], "-separate")) {
  108.             defconfig = PLANARCONFIG_SEPARATE;
  109.             continue;
  110.         }
  111.         if (streq(argv[0], "-lsb2msb")) {
  112.             deffillorder = FILLORDER_LSB2MSB;
  113.             continue;
  114.         }
  115.         if (streq(argv[0], "-msb2lsb")) {
  116.             deffillorder = FILLORDER_MSB2LSB;
  117.             continue;
  118.         }
  119.         if (streq(argv[0], "-rowsperstrip")) {
  120.             argc--, argv++;
  121.             defrowsperstrip = atoi(argv[0]);
  122.             continue;
  123.         }
  124.         if (streq(argv[0], "-2d")) {
  125.             defg3opts = GROUP3OPT_2DENCODING;
  126.             continue;
  127.         }
  128.         if (streq(argv[0], "-fill")) {
  129.             defg3opts |= GROUP3OPT_FILLBITS;
  130.             continue;
  131.         }
  132.         if (streq(argv[0], "-predictor")) {
  133.             argc--, argv++;
  134.             defpredictor = atoi(argv[0]);
  135.             continue;
  136.         }
  137.         if (streq(argv[0], "-ignore")) {
  138.             ignore = 1;
  139.             continue;
  140.         }
  141.         usage();
  142.     }
  143.     out = TIFFOpen(argv[argc-1], "w");
  144.     if (out == NULL)
  145.         exit(-2);
  146.     for (; argc > 1; argc--, argv++) {
  147.         in = TIFFOpen(filename = argv[0], "r");
  148.         if (in != NULL) {
  149.             do {
  150.                 config = defconfig;
  151.                 compression = defcompression;
  152.                 predictor = defpredictor;
  153.                 fillorder = deffillorder;
  154.                 rowsperstrip = defrowsperstrip;
  155.                 g3opts = defg3opts;
  156.                 if (!tiffcp(in, out) || !TIFFWriteDirectory(out))
  157.                     goto bad;
  158.             } while (TIFFReadDirectory(in));
  159.             (void) TIFFClose(in);
  160.         }
  161.     }
  162.     (void) TIFFClose(out);
  163.     exit(0);
  164. bad:
  165.     unlink(TIFFFileName(out));
  166.     exit(1);
  167. }
  168.  
  169. static
  170. CheckAndCorrectColormap(n, r, g, b)
  171.     int n;
  172.     u_short *r, *g, *b;
  173. {
  174.     int i;
  175.  
  176.     for (i = 0; i < n; i++)
  177.         if (r[i] >= 256 || g[i] >= 256 || b[i] >= 256)
  178.             return;
  179.     TIFFWarning(filename, "Scaling 8-bit colormap");
  180. #define    CVT(x)        (((x) * ((1L<<16)-1)) / 255)
  181.     for (i = 0; i < n; i++) {
  182.         r[i] = CVT(r[i]);
  183.         g[i] = CVT(g[i]);
  184.         b[i] = CVT(b[i]);
  185.     }
  186. #undef CVT
  187. }
  188.  
  189. static struct cpTag {
  190.     long    tag;
  191.     short    count;
  192.     TIFFDataType type;
  193. } tags[] = {
  194.     { TIFFTAG_SUBFILETYPE,        1, TIFF_LONG },
  195.     { TIFFTAG_PHOTOMETRIC,        1, TIFF_SHORT },
  196.     { TIFFTAG_THRESHHOLDING,    1, TIFF_SHORT },
  197.     { TIFFTAG_DOCUMENTNAME,        1, TIFF_ASCII },
  198.     { TIFFTAG_IMAGEDESCRIPTION,    1, TIFF_ASCII },
  199.     { TIFFTAG_MAKE,            1, TIFF_ASCII },
  200.     { TIFFTAG_MODEL,        1, TIFF_ASCII },
  201.     { TIFFTAG_ORIENTATION,        1, TIFF_SHORT },
  202.     { TIFFTAG_MINSAMPLEVALUE,    1, TIFF_SHORT },
  203.     { TIFFTAG_MAXSAMPLEVALUE,    1, TIFF_SHORT },
  204.     { TIFFTAG_XRESOLUTION,        1, TIFF_RATIONAL },
  205.     { TIFFTAG_YRESOLUTION,        1, TIFF_RATIONAL },
  206.     { TIFFTAG_PAGENAME,        1, TIFF_ASCII },
  207.     { TIFFTAG_XPOSITION,        1, TIFF_RATIONAL },
  208.     { TIFFTAG_YPOSITION,        1, TIFF_RATIONAL },
  209.     { TIFFTAG_GROUP4OPTIONS,    1, TIFF_LONG },
  210.     { TIFFTAG_RESOLUTIONUNIT,    1, TIFF_SHORT },
  211.     { TIFFTAG_PAGENUMBER,        2, TIFF_SHORT },
  212.     { TIFFTAG_SOFTWARE,        1, TIFF_ASCII },
  213.     { TIFFTAG_DATETIME,        1, TIFF_ASCII },
  214.     { TIFFTAG_ARTIST,        1, TIFF_ASCII },
  215.     { TIFFTAG_HOSTCOMPUTER,        1, TIFF_ASCII },
  216.     { TIFFTAG_WHITEPOINT,        1, TIFF_RATIONAL },
  217.     { TIFFTAG_PRIMARYCHROMATICITIES,-1,TIFF_RATIONAL },
  218.     { TIFFTAG_HALFTONEHINTS,    2, TIFF_SHORT },
  219.     { TIFFTAG_BADFAXLINES,        1, TIFF_LONG },
  220.     { TIFFTAG_CLEANFAXDATA,        1, TIFF_SHORT },
  221.     { TIFFTAG_CONSECUTIVEBADFAXLINES,1, TIFF_LONG },
  222.     { TIFFTAG_INKSET,        1, TIFF_SHORT },
  223.     { TIFFTAG_INKNAMES,        1, TIFF_ASCII },
  224.     { TIFFTAG_DOTRANGE,        2, TIFF_SHORT },
  225.     { TIFFTAG_TARGETPRINTER,    1, TIFF_ASCII },
  226.     { TIFFTAG_SAMPLEFORMAT,        1, TIFF_SHORT },
  227.     { TIFFTAG_YCBCRCOEFFICIENTS,    -1,TIFF_RATIONAL },
  228.     { TIFFTAG_YCBCRSUBSAMPLING,    2, TIFF_SHORT },
  229.     { TIFFTAG_YCBCRPOSITIONING,    1, TIFF_SHORT },
  230.     { TIFFTAG_REFERENCEBLACKWHITE,    -1,TIFF_RATIONAL },
  231.     { TIFFTAG_MATTEING,        1, TIFF_SHORT },
  232. };
  233. #define    NTAGS    (sizeof (tags) / sizeof (tags[0]))
  234.  
  235. static void
  236. cpOtherTags(in, out)
  237.     TIFF *in, *out;
  238. {
  239.     struct cpTag *p;
  240.     short shortv, shortv2;
  241.     float floatv, *floatav;
  242.     char *stringv;
  243.     u_long longv;
  244.  
  245.     for (p = tags; p < &tags[NTAGS]; p++)
  246.         switch (p->type) {
  247.         case TIFF_SHORT:
  248.             if (p->count == 1) {
  249.                 CopyField(p->tag, shortv);
  250.             } else if (p->count == 2) {
  251.                 CopyField2(p->tag, shortv, shortv2);
  252.             }
  253.             break;
  254.         case TIFF_LONG:
  255.             CopyField(p->tag, longv);
  256.             break;
  257.         case TIFF_RATIONAL:
  258.             if (p->count == 1) {
  259.                 CopyField(p->tag, floatv);
  260.             } else if (p->count == -1) {
  261.                 CopyField(p->tag, floatav);
  262.             }
  263.             break;
  264.         case TIFF_ASCII:
  265.             CopyField(p->tag, stringv);
  266.             break;
  267.         }
  268. }
  269.  
  270. static int
  271. tiffcp(in, out)
  272.     TIFF *in, *out;
  273. {
  274.     short bitspersample, samplesperpixel, shortv, bystrip;
  275.     u_long w, l;
  276.  
  277.     CopyField(TIFFTAG_IMAGEWIDTH, w);
  278.     CopyField(TIFFTAG_IMAGELENGTH, l);
  279.     CopyField(TIFFTAG_BITSPERSAMPLE, bitspersample);
  280.     if (compression != (u_short)-1)
  281.         TIFFSetField(out, TIFFTAG_COMPRESSION, compression);
  282.     else
  283.         CopyField(TIFFTAG_COMPRESSION, compression);
  284.     if (fillorder != 0)
  285.         TIFFSetField(out, TIFFTAG_FILLORDER, fillorder);
  286.     else
  287.         CopyField(TIFFTAG_FILLORDER, shortv);
  288.     CopyField(TIFFTAG_SAMPLESPERPIXEL, samplesperpixel);
  289.     if (rowsperstrip < 0) {
  290.         /*
  291.          * RowsPerStrip is left unspecified: use either the
  292.          * value from the input image or, if nothing is defined,
  293.          * something that approximates 8Kbyte strips.
  294.          */
  295.         if (!TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &rowsperstrip))
  296.             rowsperstrip = (8*1024)/TIFFScanlineSize(out);
  297.     }
  298.     if (rowsperstrip == 0)
  299.         rowsperstrip = 1L;
  300.     TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip);
  301.     if (config != -1)
  302.         TIFFSetField(out, TIFFTAG_PLANARCONFIG, config);
  303.     else
  304.         CopyField(TIFFTAG_PLANARCONFIG, config);
  305.     if (g3opts != 0)
  306.         TIFFSetField(out, TIFFTAG_GROUP3OPTIONS, g3opts);
  307.     else
  308.         CopyField(TIFFTAG_GROUP3OPTIONS, g3opts);
  309.     if (samplesperpixel <= 4) {
  310.         u_short *tr, *tg, *tb, *ta;
  311.         CopyField4(TIFFTAG_TRANSFERFUNCTION, tr, tg, tb, ta);
  312.     }
  313.     if (predictor != 0)
  314.         TIFFSetField(out, TIFFTAG_PREDICTOR, predictor);
  315.     else
  316.         CopyField(TIFFTAG_PREDICTOR, predictor);
  317.     { u_short *red, *green, *blue;
  318.       if (TIFFGetField(in, TIFFTAG_COLORMAP, &red, &green, &blue)) {
  319.         CheckAndCorrectColormap(1<<bitspersample, red, green, blue);
  320.         TIFFSetField(out, TIFFTAG_COLORMAP, red, green, blue);
  321.       }
  322.     }
  323. /* TileWidth & TileLength */
  324. /* SMinSampleValue & SMaxSampleValue */
  325. /* JPEG stuff */
  326.     cpOtherTags(in, out);
  327.  
  328.     (void) TIFFGetField(in, TIFFTAG_PLANARCONFIG, &shortv);
  329.     if (shortv != config && bitspersample != 8 && samplesperpixel > 1) {
  330.         fprintf(stderr,
  331. "Can't handle different planar configuration w/ bits/sample != 8\n");
  332.         return (0);
  333.     }
  334.     { long irps = -1L;
  335.       TIFFGetField(in, TIFFTAG_ROWSPERSTRIP, &irps);
  336.       bystrip = (rowsperstrip == irps);
  337.     }
  338. #define    pack(a,b,c)    ((u_long)(((a)<<9)|((b)<<1)|(c)))
  339.     switch (pack(shortv, config, bystrip)) {
  340.     case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, 0):
  341.         return (cpContig2ContigByRow(in, out, l));
  342.     case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_CONTIG, 1):
  343.         return (cpDecodedStrips(in, out, l));
  344.     case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, 0):
  345.     case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_SEPARATE, 1):
  346.         return (cpSeparate2SeparateByRow(in, out, l, samplesperpixel));
  347.     case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, 0):
  348.     case pack(PLANARCONFIG_CONTIG, PLANARCONFIG_SEPARATE, 1):
  349.         return (cpContig2SeparateByRow(in, out, l, samplesperpixel, w));
  350.     case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, 0):
  351.     case pack(PLANARCONFIG_SEPARATE, PLANARCONFIG_CONTIG, 1):
  352.         return (cpSeparate2ContigByRow(in, out, l, samplesperpixel, w));
  353.     default:
  354.         fprintf(stderr,
  355.         "tiffcp: %s: Unknown planar configuration (in=%d out=%d).\n",
  356.             TIFFFileName(in), shortv, config);
  357.         return (0);
  358.     }
  359.     /*NOTREACHED*/
  360. }
  361.  
  362. static int
  363. cpContig2ContigByRow(in, out, imagelength)
  364.     TIFF *in, *out;
  365.     u_long imagelength;
  366. {
  367.     u_char *buf = (u_char *)malloc(TIFFScanlineSize(in));
  368.     u_long row;
  369.  
  370.     for (row = 0; row < imagelength; row++) {
  371.         if (TIFFReadScanline(in, buf, row, 0) < 0 && !ignore)
  372.             goto done;
  373.         if (TIFFWriteScanline(out, buf, row, 0) < 0)
  374.             goto bad;
  375.     }
  376. done:
  377.     free(buf);
  378.     return (1);
  379. bad:
  380.     free(buf);
  381.     return (0);
  382. }
  383.  
  384. static int
  385. cpDecodedStrips(in, out, h)
  386.     TIFF *in, *out;
  387.     u_long h;
  388. {
  389.     u_long stripsize  = TIFFStripSize(in);
  390.     u_char *buf = (u_char *)malloc(stripsize);
  391.  
  392.     if (buf) {
  393.         u_int s, ns = TIFFNumberOfStrips(in);
  394.         u_long row = 0;
  395.         for (s = 0; s < ns; s++) {
  396.             u_int cc = (row + rowsperstrip > h) ?
  397.                 TIFFVStripSize(in, h - row) : stripsize;
  398.             if (TIFFReadEncodedStrip(in, s, buf, cc) < 0 && !ignore)
  399.                 break;
  400.             if (TIFFWriteEncodedStrip(out, s, buf, cc) < 0) {
  401.                 free(buf);
  402.                 return (0);
  403.             }
  404.             row += rowsperstrip;
  405.         }
  406.         free(buf);
  407.         return (1);
  408.     }
  409.     return (0);
  410. }
  411.  
  412. static int
  413. cpSeparate2SeparateByRow(in, out, imagelength, samplesperpixel)
  414.     TIFF *in, *out;
  415.     u_long imagelength;
  416.     short samplesperpixel;
  417. {
  418.     u_char *buf = (u_char *)malloc(TIFFScanlineSize(in));
  419.     u_long row;
  420.     int s;
  421.  
  422.     for (s = 0; s < samplesperpixel; s++) {
  423.         for (row = 0; row < imagelength; row++) {
  424.             if (TIFFReadScanline(in, buf, row, s) < 0 && !ignore)
  425.                 goto done;
  426.             if (TIFFWriteScanline(out, buf, row, s) < 0)
  427.                 goto bad;
  428.         }
  429.     }
  430. done:
  431.     free(buf);
  432.     return (1);
  433. bad:
  434.     free(buf);
  435.     return (0);
  436. }
  437.  
  438. static int
  439. cpContig2SeparateByRow(in, out, imagelength, samplesperpixel, imagewidth)
  440.     TIFF *in, *out;
  441.     u_long imagelength;
  442.     short samplesperpixel;
  443.     u_long imagewidth;
  444. {
  445.     u_char *inbuf = (u_char *)malloc(TIFFScanlineSize(in));
  446.     u_char *outbuf = (u_char *)malloc(TIFFScanlineSize(out));
  447.     register u_char *inp, *outp;
  448.     register u_long n;
  449.     u_long row;
  450.     int s;
  451.  
  452.     /* unpack channels */
  453.     for (s = 0; s < samplesperpixel; s++) {
  454.         for (row = 0; row < imagelength; row++) {
  455.             if (TIFFReadScanline(in, inbuf, row, 0) < 0 && !ignore)
  456.                 goto done;
  457.             inp = inbuf + s;
  458.             outp = outbuf;
  459.             for (n = imagewidth; n-- > 0;) {
  460.                 *outp++ = *inp;
  461.                 inp += samplesperpixel;
  462.             }
  463.             if (TIFFWriteScanline(out, outbuf, row, s) < 0)
  464.                 goto bad;
  465.         }
  466.     }
  467. done:
  468.     if (inbuf) free(inbuf);
  469.     if (outbuf) free(outbuf);
  470.     return (1);
  471. bad:
  472.     if (inbuf) free(inbuf);
  473.     if (outbuf) free(outbuf);
  474.     return (0);
  475. }
  476.  
  477. static int
  478. cpSeparate2ContigByRow(in, out, imagelength, samplesperpixel, imagewidth)
  479.     TIFF *in, *out;
  480.     u_long imagelength;
  481.     int samplesperpixel;
  482.     u_long imagewidth;
  483. {
  484.     u_char *inbuf = (u_char *)malloc(TIFFScanlineSize(in));
  485.     u_char *outbuf = (u_char *)malloc(TIFFScanlineSize(out));
  486.     register u_char *inp, *outp;
  487.     register u_long n;
  488.     u_long row;
  489.     int s;
  490.  
  491.     for (row = 0; row < imagelength; row++) {
  492.         /* merge channels */
  493.         for (s = 0; s < samplesperpixel; s++) {
  494.             if (TIFFReadScanline(in, inbuf, row, s) < 0 && !ignore)
  495.                 goto done;
  496.             inp = inbuf;
  497.             outp = outbuf + s;
  498.             for (n = imagewidth; n-- > 0;) {
  499.                 *outp = *inp++;
  500.                 outp += samplesperpixel;
  501.             }
  502.         }
  503.         if (TIFFWriteScanline(out, outbuf, row, 0) < 0)
  504.             goto bad;
  505.     }
  506. done:
  507.     if (inbuf) free(inbuf);
  508.     if (outbuf) free(outbuf);
  509.     return (1);
  510. bad:
  511.     if (inbuf) free(inbuf);
  512.     if (outbuf) free(outbuf);
  513.     return (0);
  514. }
  515.  
  516. static void
  517. usage()
  518. {
  519.     fprintf(stderr, "usage: tiffcp [options] input... output\n");
  520.     fprintf(stderr, "where options are:\n");
  521.     fprintf(stderr,
  522.         " -contig\tpack samples contiguously (e.g. RGBRGB...)\n");
  523.     fprintf(stderr,
  524.         " -separate\tstore samples separately (e.g. RRR...GGG...BBB...)\n");
  525.     fprintf(stderr, "\n");
  526.     fprintf(stderr, " -lsb2msb\tforce lsb-to-msb FillOrder for output\n");
  527.     fprintf(stderr, " -msb2lsb\tforce msb-to-lsb FillOrder for output\n");
  528.     fprintf(stderr, "\n");
  529.     fprintf(stderr,
  530.         " -lzw\t\tcompress output with Lempel-Ziv & Welch encoding\n");
  531.     fprintf(stderr,
  532.         " -packbits\tcompress output with packbits encoding\n");
  533.     fprintf(stderr,
  534.         " -g3\t\tcompress output with CCITT Group 3 encoding\n");
  535.     fprintf(stderr,
  536.         " -g4\t\tcompress output with CCITT Group 4 encoding\n");
  537.     fprintf(stderr,
  538.         " -none\t\tuse no compression algorithm on output\n");
  539.     fprintf(stderr, "\n");
  540.     fprintf(stderr,
  541.         " -2d\t\tuse 2d encoding when compressing with Group 3\n");
  542.     fprintf(stderr,
  543.         " -fill\t\tzero-fill scanlines when compressing with Group 3\n");
  544.     fprintf(stderr, "\n");
  545.     fprintf(stderr,
  546.         " -rowsperstrip #\tmake each strip have no more than # rows\n");
  547.     fprintf(stderr, " -predictor\tset LZW predictor value\n");
  548.     fprintf(stderr, " -ignore\tignore read errors\n");
  549.     exit(-1);
  550. }
  551.